package com.acme.bankapp.domine.client;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import com.acme.bankapp.domine.account.Account;

public class Client {
    private Gender gender;
    private String name;
    private List<Account> accounts = new ArrayList<Account>();

    public List<Account> getAccounts() {
        return Collections.unmodifiableList(accounts);
    }

    public Client(final String name, final Gender gender) {
        this.name = name;
        this.gender = gender;
    }

    public String getClientSalutation() {
        return gender.toString() + " " + name;
    }

    public String getName() {
        return name;
    }

    public void addAccount(final Account account) {
        accounts.add(account);
    }

    public Account getAccount(final int id) {
        for (Account account : accounts) {
            if (account.getId() == id) {
                return account;
            }
        }
        return null;
    }
}
